// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env: 'keepfit-cloud',
  traceUser: true
})

const db = cloud.database()
const _ = db.command
const $ = _.aggregate

// 云函数入口函数
exports.main = async (event, context) => {
  return await db.collection("VIPSales").aggregate()
  .lookup({
    from: "User",
    localField: "_openid",
    foreignField: "openid",
    as: "VIP"
  })
  .end()
}